Repository navigation
Conversation
…a pending RPN midi1_to_midi2 is used one message at a time on live input, but drove cmidi2_convert_midi1_to_ump, a whole-buffer converter: it kept one RPN / NRPN / data entry state for all channels, emitted an RPN only on CC 38, and returned INVALID_DTE_SEQUENCE at the end of every call while one was pending, upon which the wrapper dropped the message it had just converted. A keyboard sending "CC 101, CC 100, CC 6" without CC 38, which is how most of them send their pitch bend range, made every later message of the device disappear. midi1_to_midi2 is now a stream translator with a choice of how controllers are handled, libremidi::controller_translation: - raw (the default): every channel voice message is translated on its own. CC 0, 6, 32, 38 and 96 to 101 stay controllers, a Program Change carries no bank, and a MIDI 1 consumer converting back gets the bytes that were sent, in order. - semantic: RPN, NRPN and bank select are combined into MIDI 2 messages as the UMP specification's default translation describes (Appendix D.3.3, D.3.4), with state per channel. Data entry is sent at once on CC 6 with LSB 0 and again on CC 38, the selection is kept after it, the null RPN / NRPN deselects, CC 6 / 38 with nothing selected are dropped, and CC 0 / 32 are folded into the next Program Change. In both, no error depends on earlier input, a swallowed message is a success with no output, UMPs produced before an input error are delivered, running status works within a call, and nothing allocates. SysEx still goes through cmidi2. midi2_to_midi1 delivers what it produced before an error, and reports a truncated last packet instead of reading past it. ump_input_configuration::midi1_controllers chooses the mode where MIDI 1 input is converted for a UMP client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KdPgugz48pdcaqHJAg2vid
jcelerier
force-pushed
the
fix/midi1-stream-controller-translation
branch
from
November 20, 2026 15:44
dbbacca to
e5f0d4d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
midi1_to_midi2is used one message at a time on live input, but it drovecmidi2_convert_midi1_to_ump, which is a whole-buffer converter:INVALID_DTE_SEQUENCEwhile an RPN is pending, and the wrapper then drops the message it had just converted.A keyboard sending
CC 101, CC 100, CC 6without CC 38 (how most send their pitch bend range) therefore made every later message of the device disappear, notes included, until a CC 38 arrived. This was reproduced on the ALSA sequencer with an M-Audio Keystation's exact sequence.Change
midi1_to_midi2becomes a stream translator, withlibremidi::controller_translationchoosing how controllers are handled:raw(default): every channel voice message is translated on its own. CC 0, 6, 32, 38 and 96 to 101 stay controllers, and a Program Change carries no bank. Converting back to MIDI 1 gives the bytes that were sent, in order.semantic: RPN, NRPN and bank select are combined following the UMP specification's default translation (Appendix D.3.3 / D.3.4):Sending on CC 6 is the specification's optional timeout taken to zero, and matches what CoreMIDI was reported to do. Of the translators surveyed (Linux kernel, AM_MIDI2.0Lib, JUCE, CoreMIDI, cmidi2 / ktmidi), cmidi2 and ktmidi are the only ones that keep global state or fail on a pending RPN.
In both modes:
SysEx still goes through cmidi2.
midi2_to_midi1now delivers what it produced before an error, and reports a truncated last packet instead of reading past it.ump_input_configuration::midi1_controllerspicks the mode where MIDI 1 input is converted for a UMP client.Tests
tests/unit/controller_translation.cppcovers:All 14 non-PipeWire unit tests pass in a header-only build with clang.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KdPgugz48pdcaqHJAg2vid